import time


# Функция для сортировки списка пузырьком
def bubble_sort(arr):
    n = len(arr)
    for i in range(n - 1):
        for j in range(0, n - i - 1):
            if arr[j] > arr[j + 1]:
                arr[j], arr[j + 1] = arr[j + 1], arr[j]


# Функция для чтения файла и возврата списка чисел
def read_file(filename):
    with open(filename) as file:
        numbers = [int(line.strip()) for line in file]
    return numbers


# Чтение файлов и сортировка
numbers1 = read_file("m1_sorted.txt")
numbers2 = read_file("m2_reverse.txt")
numbers3 = read_file("m3_shuffle.txt")

start_time = time.time()
bubble_sort(numbers1)
end_time = time.time()

execution_time = (end_time - start_time) * 1000
print(f'm1_sorted: {round (execution_time)} milliseconds')

start_time = time.time()
bubble_sort(numbers2)
end_time = time.time()
execution_time = (end_time - start_time) * 1000
print(f'm2_reverse: {round (execution_time)} milliseconds')

start_time = time.time()
bubble_sort(numbers3)
end_time = time.time()
execution_time = (end_time - start_time) * 1000
print(f'm3_shuffle: {round (execution_time)} milliseconds')
